package top.luo.mycat.server;

/**
 * HTTP协议工具， 主要是封装相应结果
 *
 * @author luo
 * @date 2021-03-19 10:06
 */
public class HttpProtocolUtils {

    /**
     * 成功相应头
     */
    public static String getHttpHeaderOk(long contentLength) {
        return "HTTP/1.1 200 OK \n" +
                "Content-Type: text/html \n" +
                "Content-Length: " + contentLength + " \n" +
                "\r\n";
    }

    /**
     * 404相应头
     */
    public static String getHttpHeaderNotFound() {
        String msg = "<h1>404 NOT FOUND</h1>";
        return "HTTP/1.1 404 not found \n" +
                "Content-Type: text/html \n" +
                "Content-Length: " + msg.getBytes().length + " \n" +
                "/r/n" +
                msg;
    }

}
